﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Adams.Web.Controllers
{
    public class ClassifiedsController : Controller
    {
        [AppendLayoutModel]
        public ActionResult Index()
        {
            var model = Logic.Classifieds.Index.PageLoad();
            return View(MobileCheck.IsMobile() ? "Index.Mobile" : "Index", model);
        }

        [AppendLayoutModel]
        public ActionResult List(string type, string category)
        {
            type = Shared.UrlHelper.Dec(type);
            category = Shared.UrlHelper.Dec(category);
            var model = Logic.Classifieds.List.PageLoad(type, category);
            return View(MobileCheck.IsMobile() ? "List.Mobile" : "List", model);
        }

        [AppendLayoutModel]
        public ActionResult Search(string criteria)
        {
            var model = Logic.Classifieds.Search.PageLoad(criteria);
            return View(MobileCheck.IsMobile() ? "Search.Mobile" : "Search", model);
        }

        [AppendLayoutModel]
        public ActionResult Posting(string id)
        {
            var model = Logic.Classifieds.Posting.PageLoad(id.ToInt());
            if (model.Posting == null)
            {
                return HttpNotFound();
            }
            else
            {
                return View(MobileCheck.IsMobile() ? "Posting.Mobile" : "Posting", model);
            }
        }
    }
}
